# @Author：silence
# @Email：792245022@qq.com
# @Date：2025/3/3 23:35

import urllib.request
import urllib.error

# 适用的场景：数据采集的时候，需要绕过登录，然后进入到某个页面

url = "https://weibo.cn/6451491586/info"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0",
    # cookie 中携带了微博的登录信息
    "cookie": "",
    # referer 判断当前路径是不是由上一个路径进来的
    "referer": "",
}

request = urllib.request.Request(url, headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode("utf-8")

with open("weibo.html", "w", encoding="utf-8") as fp:
    fp.write(content)
